package com.baidu.cmsService.dao;

import com.baidu.cmsCommes.pojo.Group;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @Author: BSS
 * @create: 2020/6/18/15:21
 */
@Mapper
public interface GroupDao {
    @Select("select * from t_group")
    List<Group> groupList();

    @Select("select count(*) from t_group")
    Integer selectCount();

    @Select("select * from t_group limit #{index},#{size}")
    List<Group> selectListPage(@Param("index") Integer index,@Param("size") Integer size);

    @Insert("insert into t_group (id,name,descr) value (#{group.id},#{group.name},#{group.descr})")
    @Options(useGeneratedKeys = true,keyProperty = "group.id",keyColumn = "t_group.id")
    @ResultType(Integer.class)
    Integer saveGroup(@Param("group") Group group);

    @Delete("delete from t_group where id = #{id}")
    Integer deleteGroupById(@Param("id") Integer gid);

    @Select("select * from t_group where id = #{id}")
    Group selectById(@Param("id") Integer id);

    @Update("update t_group set name = #{name},descr=#{descr} where id = #{id}")
    Integer updateGroupById(Group group);
}
